#!/bin/bash

MIRROR_ALI=registry.cn-hangzhou.aliyuncs.com

SERVICE_NAME=$1
SERVICE_VERSION=$2
SERVICE=$SERVICE_NAME:$SERVICE_VERSION

echo "build for service:$SERVICE"

mkdir -p /tmp/node_modules/$SERVICE_NAME

docker run \
    --user $(id -u):$(id -g) \
    -v $(pwd):/app -v /tmp/node_modules/$SERVICE_NAME:/app/node_modules -w /app \
    node:10.10.0 \
    bash -c "
         npm install &&\
         npm run build
    "

docker build --no-cache -t $MIRROR_ALI/westeros/$SERVICE -f docker/Dockerfile .
docker push $MIRROR_ALI/westeros/$SERVICE